<template>
    <scroll class="wrapper" ref="tabMenuScroll">
      <div class="tab-menu-item"
           v-for="(item,index) in categories"
           :key="index" :class="{active: curIndex == index}"
           @click="itemClick(index)">
        {{ item.title }}
      </div>
    </scroll>
</template>

<script>
import Scroll from "@/components/common/scroll/Scroll";

export default {
  name: "TabMenu",
  props: {
    categories: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      curIndex: 0
    }
  },
  components: {
    Scroll
  },
  methods: {
    itemClick(index){
      this.curIndex = index
      this.$emit('itemClick',index)
    }
  },
  mounted() {
    setTimeout(this.$refs.tabMenuScroll.refresh,100)
  }
}
</script>

<style scoped>
.wrapper{
  overflow: hidden;
  height: calc(100vh - 83px);
}
.tab-menu-item{
  width: 100%;
  height: 45px;
  text-align: center;
  line-height: 45px;
  font-size: 14px;
}
.tab-menu-item.active{
  font-weight: 600;
  background-color: #fff;
  border-left: 2px solid var(--color-tint);
  color: var(--color-tint);
}
</style>
